package com.ng.desktop.hr.view.customer;

import java.awt.Dimension;
import java.awt.Frame;
import java.util.Arrays;
import java.util.List;

import com.ng.desktop.hr.model.Customer;
import com.ng.desktop.hr.persistence.CustomerPersistence;
import com.ng.desktop.hr.services.NGFactoryBean;
import com.ng.framework.persistence.NGSearchParameter.Type;
import com.ng.framework.persistence.NGSearchParameter.UnaryOperation;
import com.ng.framework.view.desktop.NGEntitySelectorDialog;
import com.ng.framework.view.desktop.NGEntitySelectorField;
import com.ng.framework.view.desktop.NGTablePanel;
import com.ng.framework.view.desktop.filters.NGFilter;
import com.ng.framework.view.desktop.filters.NGTextFieldFilter;

public class CustomerEntitySelectorDialog extends NGEntitySelectorDialog<Customer, CustomerPersistence> {

	private static final long serialVersionUID = -1306560836396996812L;

	public CustomerEntitySelectorDialog(Frame owner, CustomerEntitySelector ngEntitySelectorField) {
		super(owner, ngEntitySelectorField);
		this.setTitle("Gestión de Clientes");
		this.setSize(new Dimension(1024, 600));
	}

	@Override
	protected NGTablePanel<Customer, CustomerPersistence> createTable(CustomerPersistence persistence,
			NGEntitySelectorField<Customer,CustomerPersistence> ngEntitySelectorField) {
		return new CustomerTablePanel(persistence, ngEntitySelectorField);
	}

	@Override
	protected CustomerPersistence createPersistence() {
		return (CustomerPersistence) NGFactoryBean.getInstance().getBean("customerPersistence");
	}

	@Override
	protected List<NGFilter> createFilters() {
		return Arrays.asList(new NGFilter[]{
				new NGTextFieldFilter("Nombre", Customer.class, "name", Type.STRING, UnaryOperation.LIKE),
				new NGTextFieldFilter("Apellido", Customer.class, "lastname", Type.STRING, UnaryOperation.LIKE),
				new NGTextFieldFilter("Email", Customer.class, "email", Type.STRING, UnaryOperation.LIKE)});
	}

}
